<?php
declare (strict_types = 1);

namespace app\adminapi\validate;

use think\Validate;

class Goods extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */

    protected $rule = [
        'goods_name' => 'require|unique:goods',
        'goods_price' => 'require',
        'goods_desc' => 'require',
        'goods_logo' => 'require',
        'cate_id' => 'require|number',
        'brand_id' => 'require|number',
        'type_id' => 'require|number',
//        .....省略
        'item' => 'array',
        'attr' => 'array',
        'goods_images' => 'array',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'goods_name.require' => '商品名称必填',
        'goods_price.require' => '价格必填',
        'goods_desc.require' => '商品简介必填',
        'goods_logo.require' => '商品logo必填',
        'cate_id.require' => '分类id必填',
        'cate_id.number' => '分类id必须是数字',
        'brand_id.require' => '品牌id必填',
        'brand_id.number' => '品牌id必须是数字',
        'type_id.require' => '类型id必填',
        'type_id.number' => '类型id必须是数字',
        'item.array' => '规格信息必须是数组',
        'attr.array' => '属性信息必须是数组',
        'goods_images.array' => '商品相册必须是数组',
    ];
}
